<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../lib/vue.js"></script>
</head>
<body>
    <div id="app">
        <button @click="num++">{{num}}</button>
        <input type="text" v-model="obj.userName">
    </div>

    <p></p>
</body>
<script>
    const p =document.querySelector("p");
    const vm = new Vue({
        el:"#app",
        data:{
            num:1,
            obj:{
                userName:"laowangtou"
            }
        }
    });
    vm.$watch("num",function(newValue,oldValue){
        p.innerText = newValue;
        console.log("num",newValue,oldValue);
    })
    vm.$watch("obj",function(newValue,oldValue){
        console.log("obj",newValue.userName)
    },{
        deep:true
    })

</script>
</html>